package one.three.twentyFour;

public class RemoveAfter {

	private static class Node<Item> {
		private Item item;
		private Node next;

		public boolean removeAfter(Node<Item> n) {
			if (n != null && n.next != null) {
				Node<Item> t = n.next.next;
				n.next = t;
				return true;
			}
			return false;
		}

		@Override
		public String toString() {

			return "[" + item + "]";
		}
	}

	public static void main(String[] args) {
		Node<String> f = new Node<String>();
		f.item = "0";
		Node<String> c = f;
		Node<String> five = null;
		for (int i = 1; i <= 10; i++) {
			c.next = new Node<String>();
			c.next.item = i + "";
			if (i == 5) {
				five = c.next;
			}
			c = c.next;
		}

		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}
		System.out.println("five:" + five);
		f.removeAfter(five);
		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}
	}

}
